
Partial Class admin_alertsNotificationSettings
    Inherits System.Web.UI.Page


    Protected Sub Page_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load
        ClearStatus()
        SetupJavaScript()
        If Not Page.IsPostBack Then
            Me.NotificationsScrollingGridView.Sort("NotificationSubject", SortDirection.Ascending)
        End If

    End Sub

    Private Sub SetupJavaScript()

        EntityController.JavaScriptAddChildDiv(Me.NotificationsScrollingGridView.DivClientId, CInt(Me.NotificationsScrollingGridView.ToolTip))
        ClientScript.RegisterStartupScript(Me.GetType(), "scrollDivs", EntityController.JavaScriptScrollingGridStartup(Me.NotificationsScrollingGridView), True)
        EntityController.JavaScriptSetFixedHeight(0)
        ScriptManager.RegisterClientScriptBlock(Me.NotificationsScrollingGridView, Me.NotificationsScrollingGridView.GetType(), _
        "scrollDivAsync", EntityController.JavaScriptScrollingGridStartup(Me.NotificationsScrollingGridView), True)
    End Sub


    Protected Sub NotificationsScrollingGridView_DataBound(ByVal sender As Object, ByVal e As System.EventArgs) Handles NotificationsScrollingGridView.DataBound
        AccessibilityController.AddImageToSortableGridHeaders(NotificationsScrollingGridView)
    End Sub

    Protected Sub NotificationsScrollingGridView_RowDataBound(ByVal sender As Object, ByVal e As System.Web.UI.WebControls.GridViewRowEventArgs) Handles NotificationsScrollingGridView.RowDataBound
        AccessibilityController.SetGridViewEditToolTips(e.Row, Me.NotificationsScrollingGridView)
        Dim txtSubject As TextBox = CType(e.Row.FindControl("txtSubject"), TextBox)
        If Not txtSubject Is Nothing Then
            SetFocus(txtSubject.ClientID)
        End If

        Dim notification As Cdm.DataCore.CaseNotes.Notification = e.Row.DataItem
        Dim activeImage As Image = e.Row.FindControl("WillEmailImage")
        If Not activeImage Is Nothing Then
            If notification.WillEmail = True Then
                activeImage.ImageUrl = "~/images/greencheck.gif"
            Else
                activeImage.ImageUrl = "~/images/blankcheck.gif"
            End If
        Else
            Dim activeCheckbox As CheckBox = e.Row.FindControl("EditWillEmailCheckbox")
            If Not activeCheckbox Is Nothing Then
                activeCheckbox.Checked = notification.WillEmail
                activeCheckbox.InputAttributes.Add("title", "Will this notification be accompanied by an email?")
            End If
        End If
    End Sub

    Private Sub SetStatus(ByVal message As String)
        Me.NotificationsScrollingGridView.StatusText = message
    End Sub

    Private Sub ClearStatus()
        SetStatus("")
    End Sub

    Protected Sub NotificationsScrollingGridView_RowUpdated(ByVal sender As Object, ByVal e As System.Web.UI.WebControls.GridViewUpdatedEventArgs) Handles NotificationsScrollingGridView.RowUpdated
        SetStatus("Notification Settings updated.")
    End Sub

    Protected Sub NotificationsScrollingGridView_RowUpdating(ByVal sender As Object, ByVal e As System.Web.UI.WebControls.GridViewUpdateEventArgs) Handles NotificationsScrollingGridView.RowUpdating
        NotificationsScrollingGridView.EditIndex = -1
    End Sub
End Class
